/*
 * FileLocationFactory.java
 *
 * Created on 05 May 2007, 12:01
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.cardcopier.file;

import java.io.File;

/**
 *
 * @author Mark
 */
public class FileLocationFactory {

    private final boolean isFileSystemCaseSensitive;
    private final String[] fileExtensions;
    
    public FileLocationFactory(String[] fileExtensions) {
        this.isFileSystemCaseSensitive = checkFileSystemCaseSensitivity();
        this.fileExtensions = fileExtensions;
    }

    public FileLocation createFileLocation(File directory) {
        if (isFileSystemCaseSensitive) {
            return new CaseSensitiveFileLocation(directory, fileExtensions);
        } else {
            return new CaseInsensitiveFileLocation(directory, fileExtensions);
        }
    }

    public boolean isIsFileSystemCaseSensitive() {
        return isFileSystemCaseSensitive;
    }
    
    private boolean checkFileSystemCaseSensitivity() {
        String osName = System.getProperty("os.name");
        return !osName.startsWith("Windows");
    }
}
